<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>流程类型列表</title>
		<%@ include file="../jslib/jquerylib.jsp"%>
		<script type="text/javascript" src="resources/js/mypage.js"></script>
		<script type="text/javascript" src="js/commontdm.js"></script>
		<link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
		<style>
		html,body {
			margin: 0;
			padding: 0;
			font-family: "Microsoft YaHei";
			font-size: 12.5px;;
		}
		
		.button_b{cursor:hand;}
		
		</style>
		<script type="text/javascript" >
		$(document).ready(function(){ 
						$("#gridTable").jqGrid({
							url:common_contextPath+'/flow/flowtypeAction!GetFlowTypeList.action',
							datatype: "json",
							height: "400",
							autowidth: true, 
							colNames:['ID','流程名称','文件名称'],
							colModel:[
								{name:'ID',index:'0', width:60, sorttype:"int",hidedlg:true},  
								{name:'FLOWNAME',align:'center',index:'1',width:'400' },
								{name:'FILENAME',align:'center',index:'2',width:'150'  }
							],   
							shrinkToFit:false,
							sortname:'ID',
							sortorder:'desc',
							viewrecords:true,
							multiselect:true, // 是否显示复选框
							multiboxonly :true, 
							gridview:true,  //提升速度
							rownumbers:true,//显示行号
							rownumWidth:20, //行号的宽度
							rowNum:20,
							rowList:[10,20,30],
							jsonReader: {
								root:"rows",		// 数据行（默认为：rows）
								page: "page",  	// 当前页
								total: "total",  // 总页数
								records: "records",  // 总记录数
								repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
							},
							prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
							pager:"#gridPager",
							caption: "流程类型列表"
					});
					jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
					jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
							{ 	
							caption: "列状态",                          
							title: "Reorder Columns",                           
							onClickButton : function (){                               
							jQuery("#gridTable").jqGrid('setColumns');                           
							}
					}); 
		});  

		//添加流程类型
		function AddFlowType(){
			var temp =window.showModalDialog("FlowTypeAdd.jsp?filename=D0000000040.xml",null,"dialogWidth=1050px;dialogHeight=650px;resizable=yes");
			refresh();
		}
		
		function EditFlowType(){
			var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow");
			if (ids.length == 0) {   
			    alert("请先选择一条数据!");  
			    return false;  
				} 
			if(ids.length > 1){
				alert("只能选择一条数据！");
				return false;
			}
			var row = $("#gridTable").jqGrid("getRowData", ids);
			var id = row.ID;
			var flowname = row.FLOWNAME;
			var filename = row.FILENAME;
			var toUrl = "FlowTypeAdd.jsp?id="+id+"&flowname="+encodeURIComponent(flowname)+"&filename="+filename+"&temp="+Math.round(Math.random()*10000);
			var temp =window.showModalDialog(toUrl,null,"dialogWidth=1050px;dialogHeight=650px;resizable=yes");
			refresh();
		}
		
		function ViewFlowType(){
			var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow");
			if (ids.length == 0) {   
			    alert("请先选择一条数据!");  
			    return false;  
				} 
			if(ids.length > 1){
				alert("只能选择一条数据！");
				return false;
			}
			var row = $("#gridTable").jqGrid("getRowData", ids);
			var id = row.ID;
			var flowname = row.FLOWNAME;
			var filename = row.FILENAME;
			var toUrl = "FlowTypeAddView.jsp?id="+id+"&flowname="+encodeURIComponent(flowname)+"&filename="+filename+"&temp="+Math.round(Math.random()*10000);
			var temp =window.showModalDialog(toUrl,null,"dialogWidth=1050px;dialogHeight=650px;resizable=yes");
		}
		
		function CopyFlowUrl(){
			var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow");
			if (ids.length == 0) {   
			    alert("请先选择一条数据!");  
			    return false;  
				} 
			if(ids.length > 1){
				alert("只能选择一条数据！");
				return false;
			}
			var row = $("#gridTable").jqGrid("getRowData", ids);
			var id = row.ID;
			window.open("CopyFlowUrl.jsp?id="+id,'newwindow','height=100,width=200,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=yes,location=no, status=no'); 
		}
		
		function DelFlowType()
		{
			var ids = $("#gridTable").jqGrid("getGridParam","selarrrow");
			if (ids.length == 0) {   
			    alert("请先选择一条数据!");  
			    return false;  
				} 
			if(ids.length > 1){
				alert("只能选择一条数据！");
				return false;
			}
			if(!confirm("是否确认删除？")){
               return false;
            }
			var row = $("#gridTable").jqGrid("getRowData", ids);
			var id = row.ID;
			
			var params = {  "id" : id};  
		    var actionUrl = common_contextPath+"/flow/flowtypeAction!DelFlowTypeById.action";  
		    $.ajax({  
		        url : actionUrl,  
		        data : params,  
		        dataType : "json",  
		        cache : false,  
		        error : function(textStatus, errorThrown) {  
		            alert("系统ajax交互错误: " + textStatus);  
		        },  
		        success : function(data, textStatus) {  
		          	alert("删除成功！");
		          	refresh();
		        }  
		    });  
		}
		
		function Designreport(){
			var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow");
			if (ids.length == 0) {   
			    alert("请先选择一条数据!");  
			    return false;  
				} 
			if(ids.length > 1){
				alert("只能选择一条数据！");
				return false;
			}
			var row = $("#gridTable").jqGrid("getRowData", ids);
			var id = row.ID;
			var toUrl = '<%=request.getContextPath() %>/codeReviewActionNew!initDesignreportNew.action?id='+id;
			var temp = window.showModalDialog(toUrl,null,"dialogWidth=1100px;dialogHeight=650px;resizable=yes");
		}
		
		function refresh()
		{
			document.location.href='FlowTypeList.jsp';
		}

		</script>
		
	</head>

	<body style="margin-bottom: 0px">
		<table width="100%" >
			<tr>
				<td>
					<div class="title" style="cursor: hand">
						<div style="float: left">
							您的当前位置： 首页 &gt;&gt;流程管理&gt;&gt;
							<strong>流程类型列表</strong>
						</div>
					</div>
				</td>
			</tr>
			
			<tr>
				<td>
					<input type='button' value='添加流程类型' class='button_b' onclick="AddFlowType()"  />
					<input type='button' value='修改流程类型' class='button_b' onclick="EditFlowType()"  />
					<input type='button' value='删除流程类型' class='button_b' onclick="DelFlowType()"/>
					<input type='button' value='查看流程类型' class='button_b' onclick="ViewFlowType()"/>
					<input type='button' value='拷贝发起地址' class='button_b' onclick="CopyFlowUrl()"/>
					<!-- <input type='button' value='设计报告' class='button_b' onclick="Designreport()"/> -->
				</td>
			</tr>
			<tr>
				<td width="100%">
					<table id="gridTable"></table>
					<div id="gridPager"></div>
				</td>
			</tr>
		</table>
	</body>
</html>